package user;

import book.Book;
import book.BookList;
import ioperations.*;

import java.util.List;

public class NormalUser extends User{
    public IOperation[] operations;
    private int choice;

    public NormalUser(String name){
        super(name);
        operations = new IOperation[]{new ListOp(), new BorrowOp(),
                    new ReturnOp(), new FindOp(), new ExitOp()};
    }
    @Override
    public void menu() {
        System.out.println("操作");
        System.out.println("1.查阅书籍");
        System.out.println("2.借阅书籍");
        System.out.println("3.归还书籍");
        System.out.println("4.查找书籍");
        System.out.println("5.退出");
    }

    @Override
    public void doOp(int choice, BookList books) {
        this.choice = choice;
        if(choice > 5 || choice < 1)
            System.out.println("非法输入");
        else operations[choice - 1].work(books);
    }
}
